<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2018/7/4
  Time: 10:46
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page isELIgnored="false" %>
<html>
<head>
    <title>添加景点</title>
        <script src="js/jquery-3.1.1.js"></script>
</head>
<body>
        <%
            Object obj =  request.getAttribute("sceTypeList");
              if(obj==null){
                  response.sendRedirect("GetSceTypeAndSceAreaServlet");
              }
        %>
        <form enctype="multipart/form-data" role="form" action="AddSceneryServlet" method="post">
                景点名称：<input type="text" name="scename"><br/><br/>
                景点描述：<textarea name="descript"></textarea><br/><br/>
                景点类型：<select name="sceType">
                                <option>请选择景点类型</option>
                                <c:forEach items="${sceTypeList}" var="sceType">
                                    <option value="${sceType.sceTypeId}">${sceType.sceName}</option>
                                </c:forEach>
                        </select><br/><br/>
                景点区域：<select name="sceArea">
                                <option>请选择景点的区域</option>
                                <c:forEach items="${areaList}" var="area">
                                    <option value="${area.areaId}">${area.areaName}</option>
                                </c:forEach>
                        </select><br/><br/>
                门票的价格:<input type="text" name="ticketPrice"><br/><br/>
                门票总数量:<input type="text" name="ticketCount"><br/><br/>
                具体地址：<input type="text" name="adress"><br/><br/>
                适宜季节：<input type="text" name="season" placeholder="请输入“春”、“春夏”、“夏秋”或“全年”形式"><br/><br/>
                开放时间：<input type="text" name="startTime"><br/><br/>
                景点星级：<input type="text" name="sceGrade"><br/><br/>
                景点的图片: <input type="file" name="picture" onchange="showImg(this)" id="uploadFile"><br/><br/>
                <div id="localImag">
                        <img id="preview" width=-1 height=-1 style="diplay:none" />
                </div>
                <button>提交</button>
        </form>
        <script>
            function showImg(file) {
                var fileVal = document.getElementById("uploadFile").value;
                var index = fileVal.indexOf(".");
                var lastName = fileVal.substring(index+1,fileVal.length);
                if(lastName=="jpg"||lastName=="png"){
                    var preview = document.getElementById('preview');
                    if(file.files && file.files[0]){
                        //火狐下
                        preview.style.display = "block";
                        preview.style.width = "300px";
                        preview.style.height = "120px";
                        preview.src = window.URL.createObjectURL(file.files[0]);
                    }else{
                        //ie下，使用滤镜
                        file.select();
                        var imgSrc = document.selection.createRange().text;
                        var localImagId = document.getElementById("localImag");
                        //必须设置初始大小
                        localImagId.style.width = "250px";
                        localImagId.style.height = "200px";
                        try{
                            localImagId.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                            locem("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
                        }catch(e){
                            alert("您上传的图片格式不正确，请重新选择!");
                            return false;
                        }
                        preview.style.display = 'none';
                        document.selection.empty();
                    }
                    return true;
                }
            }
        </script>
</body>
</html>
